package com.wei.service;

import com.wei.pojo.question;
import com.wei.util.AMSD;
import com.wei.util.AS;
import com.wei.util.MixAMSD;

import javax.script.ScriptException;
import java.util.ArrayList;
import java.util.List;

public class baseServiceImpl implements baseService{
    private AS as;
    private AMSD amsd;
    private MixAMSD mixAMSD;
    public void setAs(AS as) {
        this.as = as;
    }
    public void setAmsd(AMSD amsd) {
        this.amsd = amsd;
    }

    public void setMixAMSD(MixAMSD mixAMSD) {
        this.mixAMSD = mixAMSD;
    }

    @Override
    public List<question> Generate50AStopic() {
        ArrayList list = new ArrayList();
        question question;
        for (int i = 1; i <=50; i++) {
            question= new question();
            question.setId(i);
            question.setContent(as.calculate());
            question.setResult(as.answer());
            list.add(question);
        }
        return list;
    }

    @Override
    public List<question> Generate50AMSDtopic() {
        ArrayList list = new ArrayList();
        question question;
        for (int i = 1; i <=50; i++) {
            question= new question();
            question.setId(i);
            question.setContent(amsd.calculate());
            question.setResult(amsd.answer());
            list.add(question);
        }
        return list;
    }

    @Override
    public List<question> Generate50Mixtopic() throws ScriptException {
        ArrayList list = new ArrayList();
        question question;
        for (int i = 1; i <=50; i++) {
            question= new question();
            question.setId(i);
            question.setContent(mixAMSD.calculate());
            question.setResult(mixAMSD.answer());
            list.add(question);
        }
        return list;
    }
}
